package com.business.event;

import com.business.util.ZkClient;
import com.business.util.DerbyConn;
import org.apache.commons.dbutils.DbUtils;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;

/**
 * Created by mengdexuan on 2017/5/18 17:57.
 */
public class DealWithClosedEvent implements ApplicationListener<ContextClosedEvent> {

	private static org.slf4j.Logger log = LoggerFactory.getLogger(DealWithClosedEvent.class);

	@Override
	public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
		//关闭数据库连接
		DbUtils.closeQuietly(DerbyConn.getConn());
		//关闭 zk 客户端
		ZkClient.close();
		log.info("项目停止……");
	}
}
